package com.yimi.yinhepda.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.yimi.yinhepda.R;
import com.yimi.yinhepda.entity.bean.JoinPeopleEntity;
import java.util.List;

/**
 * 选择装卸参与人适配器
 *
 * @author 000432
 * @date 2018/5/3 0003
 */
public class SelectJoinPeopleAdapter extends BaseAdapter {

  private List<JoinPeopleEntity> mList;
  private LayoutInflater inflater;

  public SelectJoinPeopleAdapter(Context context, List<JoinPeopleEntity> list) {
    this.mList = list;
    this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }

  @Override public int getCount() {
    return mList.size();
  }

  @Override public Object getItem(int position) {
    return mList.get(position);
  }

  @Override public long getItemId(int position) {
    return position;
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = inflater.inflate(R.layout.adapter_select_join_people_item, null);
      holder.tv_workNum = (TextView) convertView.findViewById(R.id.tv_workNum);
      holder.tv_userName = (TextView) convertView.findViewById(R.id.tv_userName);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    JoinPeopleEntity entity = mList.get(position);
    holder.tv_workNum.setText(entity.getWorkNum());
    holder.tv_userName.setText(entity.getUserName());

    return convertView;
  }

  static class ViewHolder {
    TextView tv_workNum;
    TextView tv_userName;
  }
}
